﻿﻿
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>后台管理系统</title>
    <meta name="author" content="DeathGhost"/>
    <link rel="stylesheet" type="text/css" href="Css/style.css">
    <!--[if lt IE 9]>
    <script src="Scripts/html5.js"></script>
    <![endif]-->
    <script src="Scripts/jquery.js"></script>
    <script src="Scripts/jquery.mcustomscrollbar.concat.min.js"></script>
    <script>

        (function ($) {
            $(window).load(function () {

                $("a[rel='load-content']").click(function (e) {
                    e.preventDefault();
                    var url = $(this).attr("href");
                    $.get(url, function (data) {
                        $(".content .mCSB_container").append(data); //load new content inside .mCSB_container
                        //scroll-to appended content
                        $(".content").mCustomScrollbar("scrollTo", "h2:last");
                    });
                });

                $(".content").delegate("a[href='top']", "click", function (e) {
                    e.preventDefault();
                    $(".content").mCustomScrollbar("scrollTo", $(this).attr("href"));
                });

            });
        })(jQuery);
    </script>
</head>

<body>
<!--header-->
<header>
    <h1><img src="Picture/admin_logo.png"/></h1>
    <ul class="rt_nav">
        <li><a href="#" class="website_icon">站点首页</a></li>
        <li><a href="#" class="admin_icon">DeathGhost</a></li>
        <li><a href="#" class="clear_icon">清除缓存</a></li>
        <li><a href="#" class="set_icon">账号设置</a></li>
        <li><a href="login.jsp" class="quit_icon">安全退出</a></li>
    </ul>
</header>
<!--aside nav-->
<!--aside nav-->
<aside class="lt_aside_nav content mCustomScrollbar">
    <h2><a href="index.jsp">起始页</a></h2>
    <ul>
        <li>
            <dl>
                <dt>商品信息</dt>
                <!--当前链接则添加class:active-->
                <dd><a href="product_list.jsp" class="active">商品列表</a></dd>
                <dd><a href="product_detail.jsp">商品详情</a></dd>
                <dd><a href="recycle_bin.jsp">商品回收站</a></dd>
            </dl>
        </li>
        <li>
            <dl>
                <dt>订单信息</dt>
                <dd><a href="order_list.jsp">订单列表</a></dd>
                <dd><a href="order_detail.jsp">订单详情</a></dd>
            </dl>
        </li>

        <li>
            <dl>
                <dt>配送</dt>
                <dd><a href="express_list.jsp">配送方式</a></dd>
            </dl>
        </li>
        <li>
            <dl>
                <dt>在线统计</dt>
                <dd><a href="discharge_statistic.jsp" >流量统计</a></dd>
                <dd><a href="sales_volume.jsp">销售额统计</a></dd>
            </dl>
        </li>
        <li>
            <p class="btm_infor">© DeathGhost.cn 版权所有</p>
        </li>
    </ul>
</aside>
<form action="GoodsServlet?opr=update&id=${goods.goodsID}" method="post" enctype="multipart/form-data" id="inserts">
    <section class="rt_wrap content mCustomScrollbar">
        <div class="rt_content">
            <div class="page_title">
                <h2 class="fl">商品详情</h2>
                <a href="product_list.jsp" class="fr top_rt_btn gocp">返回产品列表</a>
            </div>

            <section>
                <ul class="ulColumn2">
                    <li>
                        <span class="item_name" style="width:120px;">*商品名称：</span>
                        <input type="text" class="textbox textbox_295" placeholder="商品名称..." value="${goods.goodsName}"
                               id="goodsName" name="goodsName"/>
                        <span class="errorTips" id="goodsName_err">错误提示信息...</span>
                    </li>
                    <li>
                        <span class="item_name" style="width:120px;">*价格：</span>
                        <input type="text" class="textbox" placeholder="价格..." value="${goods.price}" id="price"
                               name="price"/>
                        <span class="errorTips" id="price_err">错误提示信息...</span>
                    </li>
                    <li>
                        <span class="item_name" style="width:120px;">*库存：</span>
                        <input type="text" class="textbox" placeholder="库存数量..." value="${goods.inventory}"
                               id="inventory" name="inventory"/>
                        <span class="errorTips" id="inventory_err">错误提示信息...</span>
                    </li>
                    <li>
                        <span class="item_name" style="width:120px;">*单位：</span>

                        <select class="select" id="units" name="units">
                            <option value="斤">斤</option>
                            <option value="克">克</option>
                            <option value="包">包</option>
                            <option value="箱">箱</option>
                            <option value="台">台</option>
                            <option value="盒">盒</option>
                            <option value="袋">袋</option>
                            <option value="个">个</option>
                        </select>
                    </li>
                    <li>
                        <span class="item_name" style="width:120px;">*上传图片：</span>
                        <label class="uploadImg">
                            <input type="file" id="filePath" name="filePath"/>
                            <img width="100px" height="100px" src="${goods.filePath}" id="imgs">
                        </label>
                    </li>
                    <li>
                        <span class="item_name" style="width:120px;margin-top: 20px; margin-bottom: 10px;">商品分类：</span>
                        <select class="select" name="classify" id="classify">
                            <c:forEach items="${sessionScope.classify}" var="c">
                                <option value="${c.id}">${c.classifyName}</option>
                            </c:forEach>
                        </select>
                    </li>
                    <li>
                        <span class="item_name" style="width:120px;">商品描述：</span><br>
                        <span class="item_name" style="width:80px;"></span>
                        <textarea class="textarea" style="width:800px;height:150px;" placeholder="商品描述..." id="describe"
                                  name="describe">${goods.describe}</textarea>
                    </li>
                    <li>
                        <span class="item_name" style="width:120px; "></span>
                        <input type="submit" class="link_btn" id="but"/>
                    </li>
                </ul>
            </section>
        </div>
    </section>
    <section class="pop_bg">
        <div class="pop_cont">
            <!--title-->
            <h3>操作响应</h3>
            <!--content-->
            <!--以pop_cont_text分界-->
            <div class="pop_cont_text">
            </div>
            <!--bottom:operate->button-->
            <div class="btm_btn">
                <input type="button" value="确认" class="input_btn trueBtn" id="yz"/>
                <input type="submit" value="确认" class="input_btn trueBtn" id="tj"/>
                <input type="button" value="关闭" class="input_btn falseBtn"/>
            </div>
        </div>
    </section>
</form>

</form>
<script src="Scripts/ueditor.config.js"></script>
<script src="Scripts/ueditor.all.min.js"></script>
<script type="text/javascript">

</script>
</body>

</html>
<script src="jquery.js"></script>
<script>
    $("#classify").val(${goods.classifys});
    $("#filePath").change(function () {
        $("#sp").remove();
        $("#imgs").attr({"src": URL.createObjectURL(this.files[0]), "height": "100px", "width": "100px"})
    })

    $("#units").val("${goods.units}");

    //弹出：确认按钮
    $(".trueBtn").click(function () {
        $(".pop_bg").fadeOut();
    });
    //弹出：取消或关闭按钮
    $(".falseBtn").click(function () {
        $(".pop_bg").fadeOut();
    });
    let flag = false;
    //返回产品列表
    $(function () {
        $(".gocp").click(function () {
            location.href = 'GoodsServlet?opr=pagelist&pageNo=1';
        });

        $("#but").click(function () {
            if (name() && price() && inventory()) {
                $(".pop_cont_text").html("修改成功!");
                $("#tj").show();
                $("#yz").hide();

                $(".pop_bg").fadeIn();
            } else {
                $(".pop_cont_text").html("带*号的内容不能为空!");
                $("#yz").show();
                $("#tj").hide();

                $(".pop_bg").fadeIn();
            }
            return false;
        })
    })
    $(".errorTips").hide();
    //正则验证
    //商品名称的验证
    $("#goodsName").blur(function () {
        let goodsName = $("#goodsName").val();
        let goodsName_err = $("#goodsName_err");
        if (goodsName == "") {
            goodsName_err.html("商品名称不能为空");
            goodsName_err.show();
            return;
        } else {
            goodsName_err.hide();
        }
    })
    //商品价格的验证
    $("#inventory").blur(function () {
        let inventory = $("#inventory").val();
        let inventory_err = $("#inventory_err");
        var reg = /^\d+$/;
        if (inventory == "" || !reg.test(inventory)) {
            inventory_err.html("库存不能为空，且必须为整数！");
            inventory_err.show();
            return;
        } else {
            inventory_err.hide();
        }
    })
    //库存的验证
    $("#price").blur(function () {
        let price = $("#price").val();
        let price_err = $("#price_err");
        var reg = /^\d+(.)?\d*$/;
        if (price == "" || !reg.test(price)) {
            price_err.html("商品价格不能为空，且必须为数字！");
            price_err.show();
            return;
        } else {
            price_err.hide();
        }
    })

    //姓名
    function name() {
        let goodsName = $("#goodsName").val();
        if (goodsName == "") {
            return false;
        }
        return true;
    }

    //价格
    function price() {
        let inventory = $("#inventory").val();
        var reg = /^\d+$/;
        if (inventory == "" || !reg.test(inventory)) {
            return false;
        }
        return true;
    }

    //库存
    function inventory() {
        let price = $("#price").val();
        var reg = /^\d+(.)?\d*$/;
        if (price == "" || !reg.test(price)) {
            return false;
        }
        return true;
    }
</script>